package com.spark.gaea.utils;

public class StringCutUtil {
	public static String getCutLenthString(final String bz, final int len, final String str) {
		final String strNum = String.valueOf(str);
		if (len - strNum.length() > 0) {
			throw new RuntimeException("\u5c06\u5b57\u7b26\u4e32" + str + "\u622a\u53d6\u957f\u5ea6" + len
					+ "\u53d1\u751f\u5f02\u5e38\uff01");
		}
		if ("begin".equals(bz)) {
			return str.substring(0, len);
		}
		if ("end".equals(bz)) {
			return str.substring(str.length() - len);
		}
		return null;
	}

	public static String cutLenthString(final String bz, final int len, final String str) {
		final String strNum = String.valueOf(str);
		if (len - strNum.length() > 0) {
			throw new RuntimeException("\u5c06\u5b57\u7b26\u4e32" + str + "\u622a\u53d6\u957f\u5ea6" + len
					+ "\u53d1\u751f\u5f02\u5e38\uff01");
		}
		if ("begin".equals(bz)) {
			return str.substring(len);
		}
		if ("end".equals(bz)) {
			return str.substring(0, str.length() - len);
		}
		return null;
	}

	public static String cutXzqh(String xzqhdm) {
		if (xzqhdm != null && xzqhdm.length() == 6) {
			if ("00".equals(xzqhdm.substring(xzqhdm.length() - 2))) {
				xzqhdm = xzqhdm.substring(0, xzqhdm.length() - 2);
				if ("00".equals(xzqhdm.substring(xzqhdm.length() - 2))) {
					xzqhdm = xzqhdm.substring(0, xzqhdm.length() - 2);
				}
			}
			return xzqhdm;
		}
		return xzqhdm;
	}
}
